
#include "CMainStatu.h"
#include "NotifyEvent.h"
#include "CGUIButton.h"

CMainStatu::CMainStatu(WCHAR * name):CGUIWinControl(name)
{

}
CMainStatu::~CMainStatu(void)
{
}

void  CMainStatu::EnterStatu()
{
	OBJMGR.Parse(NULL,L"mainhome.xml");

	CGUIButton *p=(CGUIButton *)OBJMGR.GetGUIControl(L"mainhome_btn_bt");
	if (p)
		ON_CLICK(p, (NotifyFun)&CMainStatu::OnButtonPlay);

}
void  CMainStatu::ExitStatu()
{

	GUI.DelAllCtrl();
	OBJMGR.RemoveAll();

}

void  CMainStatu::OnButtonPlay()
{
	  
	//	doing = true;
		ExitStatu();
		STATUSMGR.ChangState(L"setting");
}
void CMainStatu::Update(float fDelta)
{ // Handle panel moving
	static bool up = true;
	CGUIPanel *p=(CGUIPanel *)OBJMGR.GetGUIControl(L"mainhome_panel");
	if (p==NULL)
	{
		return ;
	}
	if (doing)
	{
		int y =p->GetTop();
		if (up)
		{
			y -= 20;
		}
		else
		{
			y += 20;
		}

		if (y <= -p->GetHeight())
		{
			up = false;
		}
		else if (y >= 0)
		{
			y = 0;
			doing = false;
			up = true;

		}
		CGUIPanel *p=(CGUIPanel *)OBJMGR.GetGUIControl(L"mainhome_panel");
		p->SetTop(y);
	}
}


